<?php
class TypeModel extends Model{
	//分页获取全部图书类型
	public function getTypes($offset,$pagesize){
		$sql="SELECT tb_booktype.*,b.num FROM `{$this->table}` 
			LEFT JOIN (SELECT COUNT(*) AS num,typeid FROM tb_bookinfo GROUP BY typeid)as b 
			ON b.typeid=tb_booktype.id limit {$offset},{$pagesize}";
		return $this->db->getAll($sql);
	}
}